home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include "exinterfmotif.h"
- #include <gl.h>
- #include <sys/time.h>
- #include "exbookglo.h"
- #include "exglobals.h"
- #include "exinterf.h"
-
- extern struct filestruct *add_file();
- extern void remove_file();
- extern struct indexlist *add_keyword();
- extern struct indexlist *find_keyword();
- struct pagestruct *new_pg();
-
- /************************************************************
- *
- * Given the name of a group, find the pointer to that group.
- *
- ************************************************************/
- struct grptmpltstruct *find_group_wi_name(char *name)
- {
- struct grptmpltstruct *tmpgrp;
-
- tmpgrp = firstgroup;
- while (tmpgrp != NULL && tmpgrp->nameptr != (struct indexlist*)find_keyword(name))
- tmpgrp = tmpgrp->nextgrp;
-
- return(tmpgrp);
- }
-
- void do_print(struct grptmpltstruct *grpptr)
- {
- struct indexlist *kwrd;
- struct wordlist *wrdptr;
- struct pagestruct *tmppg;
- struct iconstruct *tmpicon;
- int i;
-
- printf("Name %s %d\n",grpptr->nameptr->string, grpptr->nameptr->num);
- printf(" %d pages %d keywords \n",grpptr->numpages, grpptr->numkey);
- wrdptr = grpptr->keywords;
- printf(" \t keywords: \n");
- for (i = 0; i < grpptr->numkey; i++)
- {
- kwrd = wrdptr->indexptr;
- printf("\t\t%s %d\n",kwrd->string, kwrd->num);
- wrdptr = wrdptr->next;
- }
- tmppg = grpptr->firstpage;
- i = 0;
- while (tmppg != NULL)
- {
- i++;
- printf(" page %d %d fronticons %d backicons \n",
- i, tmppg->frontnumicons, tmppg->backnumicons);
- tmppg = tmppg->nextpage;
- }
- printf(" icons: \n");
- tmppg = grpptr->firstpage;
- /* icons are listed in one long list across all pages */
- tmpicon = tmppg->fronticons;
- while (tmpicon != NULL)
- {
- printf("\t\t %s %d %d\n",tmpicon->iconptr->nameptr->string,
- tmpicon->xposition_ndx, tmpicon->yposition_ndx);
- tmpicon = tmpicon->nexticon;
- }
- }
-
- /************************************************************
- *
- * Print out information about the groups. Used for debugging.
- *
- ************************************************************/
- print_groups(struct grptmpltstruct *grpptr)
- {
- struct grptmpltstruct *tmpgrp;
-
- if (grpptr == NULL)
- {
- tmpgrp = firstgroup;
- while (tmpgrp != NULL)
- {
- do_print(tmpgrp);
- tmpgrp = tmpgrp ->nextgrp;
- }
- }
- else
- do_print(grpptr);
- }
-
- /************************************************************
- *
- * Restructure the alphabetical group when a demo is added
- * to the book or removed from the book.
- *
- ************************************************************/
- group_setup(struct icntmpltstruct *icnptr, struct iconstruct *iconlistptr, struct grptmpltstruct *thisgrp)
- {
- struct iconstruct *curicon, *tmplist, *previcon;
- struct iconstruct *grpcuricon, *grpprevicon;
- struct icntmpltstruct *cticn;
- struct grptmpltstruct *grpptr;
- struct pagestruct *tmppg, *newpg;
- int count, tcount;
- float half;
- double theta;
- int newnumpages;
- int x, y;
- int side;
-
- grpptr = thisgrp;
- if (grpptr != NULL)
- {
- if (iconlistptr != NULL || icnptr != NULL)
- {
- side = FRONT;
- if (iconlistptr == NULL)
- {
- cticn = icnptr;
- while (cticn != NULL)
- {
- tmplist = (struct iconstruct *)malloc(sizeof(struct iconstruct) );
- if (iconlistptr == NULL)
- iconlistptr = tmplist;
- else
- curicon->nexticon = tmplist;
- curicon = tmplist;
- curicon->nexticon = NULL;
- curicon->iconptr = cticn;
- curicon->ok = cticn->ok;
- cticn = cticn->nexticntmplt;
- }
- }
- newpg = NULL;
- count = 0;
- tcount = 0;
- curicon = iconlistptr;
- x = 0;
- y = 3;
- grpptr->ok = FALSE;
- tmppg = grpptr->firstpage;
- newnumpages = 1;
- if (side == FRONT)
- grpcuricon = tmppg->fronticons;
- else
- grpcuricon = tmppg->backicons;
- grpprevicon = NULL;
- while (curicon != NULL)
- {
- if (count < ICONLIMIT)
- {
- if (grpcuricon == NULL)
- {
- grpcuricon = (struct iconstruct *)malloc( sizeof(struct iconstruct ));
- grpcuricon->nexticon = NULL;
- if (side == FRONT)
- {
- if (tmppg->fronticons == NULL)
- tmppg->fronticons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- }
- else /* side = back */
- {
- if (tmppg->backicons == NULL)
- tmppg->backicons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- }
- }
- }
- else
- {
- if (side == FRONT)
- {
- tmppg->frontnumicons = tcount;
- side = BACK; /* back */
- if (grpcuricon == NULL)
- {
- grpcuricon =(struct iconstruct *)malloc(sizeof(struct iconstruct ));
- grpcuricon->nexticon = NULL;
- }
- tmppg->backicons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- x = 4;
- y = 3;
- }
- else /* already did the back of the page */
- {
- newnumpages++;
- tmppg->backnumicons = tcount;
- side = FRONT;
- if (tmppg->nextpage == NULL)
- {
- newpg = new_pg();
- tmppg->nextpage = newpg;
- newpg->prevpage = tmppg;
- newpg->direction = tmppg->direction;
- grpptr->lastpage = newpg;
- }
- tmppg = tmppg->nextpage;
- if (grpcuricon == NULL)
- {
- grpcuricon =(struct iconstruct *)malloc(sizeof(struct iconstruct ));
- grpcuricon->nexticon = NULL;
- }
- tmppg->fronticons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- x = 0;
- y = 3;
- }
- count = 0;
- tcount = 0;
- }
- grpprevicon = grpcuricon;
- grpcuricon->xposition_ndx = x;
- grpcuricon->yposition_ndx = y;
- grpcuricon->iconptr = curicon->iconptr;
- grpcuricon->ok = curicon->ok;
- if (grpcuricon->ok)
- grpptr->ok = TRUE;
- if (!Hide || curicon->ok)
- {
- if (side == FRONT)
- {
- x++;
- if (x > 4)
- {
- y--;
- x = 0;
- }
- }
- else
- {
- x--;
- if (x < 0)
- {
- y--;
- x = 4;
- }
- }
- count++;
- }
- previcon = curicon->nexticon;
- free(curicon);
- curicon = previcon;
- grpcuricon = grpcuricon->nexticon;
- tcount++;
- } /* endof while curicon */
- grpprevicon->nexticon = NULL;
- if (side == FRONT)
- {
- tmppg->frontnumicons = tcount;
- tmppg->backnumicons = 0;
- tmppg->backicons = NULL;
- }
- else
- tmppg->backnumicons = tcount;
- }
- else /* icnptr & iconlist == NULL if I get here */
- {
- newpg = NULL;
- count = 0;
- tcount = 0;
- x = 0;
- y = 3;
- tmppg = grpptr->firstpage;
- newnumpages = 1;
- side = FRONT;
- grpcuricon = tmppg->fronticons;
- while (grpcuricon != NULL)
- {
- if (count >= ICONLIMIT)
- {
- if (side == FRONT)
- {
- tmppg->frontnumicons = tcount;
- side = BACK;
- tmppg->backicons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- x = 4;
- y = 3;
- }
- else /* side == BACK */
- {
- newnumpages++;
- tmppg->backnumicons = tcount;
- side = FRONT;
- if (tmppg->nextpage == NULL)
- {
- newpg = new_pg();
- tmppg->nextpage = newpg;
- newpg->prevpage = tmppg;
- newpg->direction = tmppg->direction;
- grpptr->lastpage = newpg;
- }
- tmppg = tmppg->nextpage;
- tmppg->fronticons = grpcuricon;
- if (grpprevicon != NULL)
- grpprevicon->nexticon = grpcuricon;
- x = 0;
- y = 3;
- }
- count = 0;
- tcount = 0;
- } /* end if if count >= ICONLIMIT */
- grpprevicon = grpcuricon;
- grpcuricon->xposition_ndx = x;
- grpcuricon->yposition_ndx = y;
- if (!Hide || grpcuricon->ok)
- {
- if (side == FRONT)
- {
- x++;
- if (x > 4)
- {
- y--;
- x = 0;
- }
- }
- else
- {
- x--;
- if (x < 0)
- {
- y--;
- x = 4;
- }
- }
- count++;
- }
- grpcuricon = grpcuricon->nexticon;
- tcount++;
- }
- if (side == FRONT)
- {
- tmppg->frontnumicons = tcount;
- tmppg->backicons = NULL;
- tmppg->backnumicons = 0;
- }
- else
- tmppg->backnumicons = tcount;
- }
- while (newnumpages < grpptr->numpages)
- {
- grpptr->numpages--;
- tmppg = grpptr->lastpage;
- grpptr->lastpage = tmppg->prevpage;
- tmppg->prevpage = NULL;
- grpptr->lastpage->nextpage = NULL;
- /*
- free(tmppg);
- */
- }
- grpptr->numpages = newnumpages;
- }
- }
-
- void setup_all_groups()
- {
- struct grptmpltstruct *grpptr;
- struct pagestruct *tmppg;
- Boolean found;
-
- grpptr = firstgroup;
-
- while (grpptr != NULL)
- {
- group_setup(NULL, NULL, grpptr);
- if (grpptr == curgroup && rightpage != grpptr->firstpage)
- {
- found = FALSE;
- tmppg = grpptr->firstpage;
- while (!found && tmppg != NULL)
- {
- if (leftpage == tmppg)
- found = TRUE;
- else
- tmppg = tmppg->nextpage;
- }
- if (!found)
- {
- leftpage = NULL;
- rightpage = grpptr->firstpage;
- }
- else if (leftpage->backicons == NULL)
- {
- rightpage = leftpage;
- leftpage = leftpage->prevpage;
- }
- }
- grpptr = grpptr->nextgrp;
- }
- }
-
- /************************************************************
- *
- * Set the view matrix for the part of the group window that
- * contains the new page.
- *
- ************************************************************/
- setgroupview()
- {
- long winsize_x, winsize_y;
- float xratio, ydif;
-
- getsize(&winsize_x, &winsize_y);
- viewport(0, winsize_x-1, 0, winsize_y -1);
- ortho2(0.0, (float)PGWIDTH, 0.0, (float)PGHEIGHT);
- }
-
- setgpform(struct grptmpltstruct *grpptr)
- {
- struct charlist *curchar, *prevchar;
- struct wordlist *wrdptr;
- struct indexlist *ndxptr;
- int count;
- long cumlength, limit;
- static short nblocks_grp = 1;
-
- if (grpptr != NULL)
- {
- /* Moved init of Exist Keyword List to initgpform */
- /*
- ndxptr = Index;
- count = 0;
- ExistKeywordString[0] = '\0';
- strcpy(ExistKeywordString, "");
- while (ndxptr != NULL) {
- count++;
- strcat(ExistKeywordString, (ndxptr->string));
- strcat(ExistKeywordString, ",");
- ndxptr = ndxptr->next;
- }
- ExistKeywordCount = count;
- */
-
- AGName.bufpos = strlen(grpptr->nameptr->string);
- strcpy(AGName.buf, grpptr->nameptr->string);
- count = 0;
- GroupKeywordString[0] = '\0';
- strcpy(GroupKeywordString, "");
- wrdptr = grpptr->keywords;
- limit = (512 *nblocks_grp) - 2;
- cumlength = 0;
- while (wrdptr != NULL)
- {
- curchar = (struct charlist *) malloc(sizeof(struct charlist) );
- curchar->str = NULL;
- curchar->next = NULL;
- if (HeadGrpChar == NULL)
- HeadGrpChar = curchar;
- else
- TailGrpChar->next = curchar;
- TailGrpChar = curchar;
- TailGrpChar->indexflag = 1;
- TailGrpChar->str = (char *) malloc(strlen(wrdptr->indexptr->string)+1 );
- strcpy(TailGrpChar->str, wrdptr->indexptr->string) ;
- cumlength+=(strlen(wrdptr->indexptr->string)+1);
- if (cumlength > limit)
- {
- nblocks_grp++;
- GroupKeywordString = (char *)realloc( (void *)GroupKeywordString,
- 512*nblocks_grp);
- limit = (512 *nblocks_grp) - 2;
- }
- strcat(GroupKeywordString, (wrdptr->indexptr->string));
- strcat(GroupKeywordString, ",");
- count++;
- wrdptr = wrdptr->next;
- }
- GroupKeywordCount = count;
- }
- }
-
- /************************************************************
- *
- * Initialize the window for adding a new group.
- *
- ************************************************************/
- void initgroupwin(struct grptmpltstruct *grp)
- {
- initgpform();
- setgpform(grp);
- dogroupview();
- }
-
- struct grptmpltstruct *new_grp()
- {
- struct grptmpltstruct *newgrp;
-
- newgrp = (struct grptmpltstruct *) malloc(sizeof(struct grptmpltstruct));
- newgrp->nameptr = NULL;
- newgrp->numpages = 0;
- newgrp->nextgrp = NULL;
- newgrp->prevgrp = NULL;
- newgrp->firstpage = NULL;
- newgrp->lastpage = NULL;
- newgrp->helpfile = NULL;
- newgrp->numkey = 0;
- newgrp->keywords = NULL;
- newgrp->arttype = 0;
- newgrp->covercolor[0] = 1.0;
- newgrp->covercolor[1] = 0.0;
- newgrp->covercolor[2] = 0.0;
-
- return(newgrp);
- }
-
- struct pagestruct *new_pg()
- {
- struct pagestruct *newpg;
-
- newpg = (struct pagestruct *)malloc(sizeof(struct pagestruct) );
- newpg->fronticons = NULL;
- newpg->backicons = NULL;
- newpg->markerptr = NULL;
- newpg->frontnumicons = 0;
- newpg->backnumicons = 0;
- newpg->direction = 1;
- newpg->pgnum = 0;
- newpg->prevpage = NULL;
- newpg->nextpage = NULL;
-
- return(newpg);
- }
-
- /************************************************************
- *
- * allocate the new storage for the new group.
- *
- ************************************************************/
- initgroup()
- {
- newgrpptr = new_grp();
- /* group_setup assumes that there is a first page */
- newgrpptr->firstpage = new_pg();
- newgrpptr->lastpage = newgrpptr->firstpage;
- newgrpptr->lastpage->nextpage = NULL;
-
- curnewpage = newgrpptr->firstpage;
- newgroupiconlist = NULL;
- newgrouplasticon = NULL;
-
- /* for interface */
- AGColor[0] = 1.0;
- AGColor[1] = 0.0;
- AGColor[2] = 0.0;
- }
-
- /************************************************************
- *
- * Delete a group. All of its pages and each page's references
- * to icons must also be deleted.
- *
- ************************************************************/
- int deletegroup(struct grptmpltstruct *delgrp)
- {
- struct grptmpltstruct *tmpgrp, *tmp2;
- struct pagestruct *pg1, *pg2;
- struct wordlist *wrd1, *wrd2;
- struct iconstruct *tmpicon, *previcon;
- struct grpliststruct *glistptr, *prevglist;
- int i;
- Boolean found;
-
- /* need a test to make sure that the
- alphabetical group does not get deleted */
- if (delgrp->nameptr != find_keyword("Master Index"))
- {
- if (delgrp == curgroup)
- {
- DialogType = 3;
- sprintf(msgstring,"%s",delgrp->nameptr->string);
- popup_Question();
- handleMessageEvents();
- if(DeleteGroupFlag != TRUE)
- return(0);
- }
- if (delgrp == firstgroup)
- {
- firstgroup = delgrp->nextgrp;
- firstgroup->prevgrp = NULL;
- }
- else if (delgrp == lastgroup)
- {
- lastgroup = delgrp->prevgrp;
- lastgroup->nextgrp = NULL;
- }
- else
- {
- tmpgrp = delgrp->nextgrp;
- tmpgrp->prevgrp = delgrp->prevgrp;
- tmpgrp = delgrp->prevgrp;
- tmpgrp->nextgrp = delgrp->nextgrp;
- }
- /* this stuff will free up all of the pointers
- that had memory allocated for them. */
- delgrp->nameptr->group = NULL;
- remove_keyword(delgrp->nameptr);
- remove_file(delgrp->helpfile);
- delete_keywords(delgrp, 1);
- pg1 = delgrp->firstpage;
- while (pg1 != NULL)
- {
- pg2 = pg1->nextpage;
- /* need to decrement the icon count */
- tmpicon = pg1->fronticons;
- while (tmpicon != NULL)
- {
- (tmpicon->iconptr->occurences)--;
- glistptr = tmpicon->iconptr->grps;
- prevglist = NULL;
- found = FALSE;
- while (glistptr != NULL && !found)
- {
- if (glistptr->grpptr == delgrp)
- {
- found = TRUE;
- if (glistptr == tmpicon->iconptr->grps)
- tmpicon->iconptr->grps = tmpicon->iconptr->grps->next;
- else if (glistptr->next == NULL)
- {
- if (prevglist != NULL)
- prevglist->next = NULL;
- }
- else
- {
- prevglist->next = glistptr->next;
- }
- free(glistptr);
- glistptr = NULL;
- }
- else
- {
- prevglist = glistptr;
- glistptr = glistptr->next;
- }
- }
- previcon = tmpicon;
- free(previcon);
- tmpicon = tmpicon->nexticon;
- }
- free(pg1);
- pg1 = pg2;
- }
- tmpgrp = delgrp->nextgrp;
- tmp2 = delgrp->prevgrp;
- if (delgrp == curgroup)
- curgroup = NULL;
- free(delgrp);
- delgrp = NULL;
- rightpage = NULL;
- leftpage = NULL;
- numberofgroups--;
- initbookpos();
- OPENBOOK = FALSE;
- resetshelfcolors();
- if (Indexwin >= 0)
- update_index_win();
- return(1);
- }
- else
- {
- sprintf(msgstring, "The Master Index book can not be deleted.");
- popup_Message();
- return(0);
- }
- }
-
- /************************************************************
- *
- * Allows the user to edit the group information.
- *
- ************************************************************/
- long editgroup()
- {
- long rslt;
- struct iconstruct *tmpiconlist, *grpicons;
- struct pagestruct *tmppage;
- int i;
- int side;
-
- rslt = -1;
- if (curgroup->nameptr != find_keyword("Master Index"))
- {
- rslt = 1;
- AGColor[0] = curgroup->covercolor[0];
- AGColor[1] = curgroup->covercolor[1];
- AGColor[2] = curgroup->covercolor[2];
- newgrpptr = curgroup;
- curnewpage = newgrpptr->firstpage;
- EditGroupFlag = 1;
- initgroupwin(curgroup);
- /* set name field to group name */
- /* put keywords in the list */
- /* set up list of icons */
- tmppage = curgroup->firstpage;
- while (tmppage != NULL)
- {
- side = FRONT;
- grpicons = tmppage->fronticons;
- newgroupnumicons = tmppage->frontnumicons + tmppage->backnumicons;
- for (i = 0; i < newgroupnumicons; i++)
- {
- tmpiconlist = (struct iconstruct *)malloc(sizeof(struct iconstruct) );
- if (newgroupiconlist == NULL)
- newgroupiconlist = tmpiconlist;
- else
- newgrouplasticon->nexticon = tmpiconlist;
- newgrouplasticon = tmpiconlist;
- tmpiconlist->iconptr = grpicons->iconptr;
- tmpiconlist->ok = grpicons->ok;
- tmpiconlist->xposition_ndx = grpicons->xposition_ndx;
- tmpiconlist->yposition_ndx = grpicons->yposition_ndx;
- tmpiconlist->nexticon = NULL;
- grpicons = grpicons->nexticon;
- if (side == FRONT && grpicons == NULL)
- {
- side = BACK;
- grpicons = tmppage->backicons;
- }
- }
- tmppage = tmppage->nextpage;
- }
- }
- return(rslt);
- }
-
- /************************************************************
- *
- * Draw section of the group window that contains the page.
- *
- ************************************************************/
- drawgroupwin()
- {
- float x, y;
- struct iconstruct *iconlist;
- float transname;
-
- dogroupview();
- c3s(morecolors[9]);
- clear();
- /* drawflaticons here */
- iconlist = newgroupiconlist;
- x = 0.55;
- y = PGHEIGHT - 1.8;
- while (iconlist != NULL)
- {
- transname = -.15;
- pushmatrix();
- translate(x, y, 0.0);
- scale(.7, .7, 1.0);
- if (iconlist->iconptr->poly != NULL)
- drawicon_geom(0, iconlist->iconptr);
- /*
- else if (iconlist->iconptr->tex_image != NULL)
- drawicon_img(0,iconlist->iconptr);
- */
- else
- transname = 1.125;
- pushmatrix();
- translate(0.0, transname, 0.0);
- draw_demoname(iconlist->iconptr);
- popmatrix();
- popmatrix();
- x = x + 1.5;
- if (x > (PGWIDTH-1.0))
- {
- x = 0.75;
- y = y - 2.0;
- }
- iconlist = iconlist->nexticon;
- }
- swapbuffers();
- }
-
- void pickdrawgroupwin()
- {
- short pickname;
- float x, y;
- struct iconstruct *iconlist;
-
- iconlist = newgroupiconlist;
- x = 0.75;
- y = PGHEIGHT - 2.0;
- pickname = 0;
- while (iconlist != NULL)
- {
- loadname(pickname);
- c3s(morecolors[20+pickname]);
- rectf(x, y, x+1.5, y+2.0);
- x = x + 1.5;
- if (x > (PGWIDTH-1.0))
- {
- x = 0.75;
- y = y - 2.0;
- }
- iconlist = iconlist->nexticon;
- pickname++;
- }
- }
-
- void findicon(float mx, float my, float *ix, float *iy)
- {
- int numrows;
- float wy, wx;
-
- numrows = newgroupnumicons/6; /* 6 = num icons across window */
- wy = (PGHEIGHT - 2.0) - (numrows * 2.0);
- *ix = -1;
- *iy = -1;
- }
-
- void highlightgroupicon(float ix, float iy)
- {
- /* already in PUP drawmode */
- dogroupview();
- color(PUP_WHITE);
- rect(ix, iy, ix+1.5, iy+2.0);
-
- }
-
- /************************************************************
- *
- * Make sure all of the demos in this group have a pointer
- * back to the group.
- *
- ************************************************************/
- check_demos(struct grptmpltstruct *grpptr)
- {
- struct pagestruct *tmppg;
- struct grptmpltstruct *tmpgrp;
- struct grpliststruct *glistptr;
- struct iconstruct *tmpiconptr;
- int i;
- Boolean found;
- int tmpnum, side;
-
- tmppg = grpptr->firstpage;
- while (tmppg != NULL)
- {
- side = FRONT;
- tmpiconptr = tmppg->fronticons;
- tmpnum = tmppg->frontnumicons + tmppg->backnumicons;
- for (i = 0; i < tmpnum; i++)
- {
- found = FALSE;
- glistptr = tmpiconptr->iconptr->grps;
- while (glistptr != NULL && !found)
- {
- if (glistptr->grpptr == grpptr)
- found = TRUE;
- else
- glistptr = glistptr->next;
- }
- if (!found)
- {
- glistptr = (struct grpliststruct *)malloc(sizeof(struct grpliststruct) );
- glistptr->next = NULL;
- glistptr->prev = NULL;
- glistptr->grpptr = grpptr;
- if (tmpiconptr->iconptr->grps == NULL)
- tmpiconptr->iconptr->grps = glistptr;
- else
- {
- glistptr->next = tmpiconptr->iconptr->grps;
- tmpiconptr->iconptr->grps = glistptr;
- }
- }
- tmpiconptr = tmpiconptr->nexticon;
- if (tmpiconptr == NULL && side == FRONT)
- {
- side = BACK;
- tmpiconptr = tmppg->backicons;
- }
- }
- tmppg = tmppg->nextpage;
- }
- }
-
- void clear_iconlist(struct iconstruct *ic)
- {
- struct iconstruct *tmpicon, *previcon;
-
- tmpicon = ic;
- while (tmpicon != NULL)
- {
- previcon = tmpicon;
- tmpicon = tmpicon->nexticon;
- free(previcon);
- }
- }
-
- void savegroupchanges(struct grptmpltstruct *grpptr)
- {
- struct indexlist *tmpptr;
- struct charlist *charptr, *prevcharptr;
- struct wordlist *wrdptr, *twrd;
- int i;
- Boolean indexchange;
- struct iconstruct *tmpicon;
-
- indexchange = FALSE;
- grpptr->covercolor[0] = AGColor[0];
- grpptr->covercolor[1] = AGColor[1];
- grpptr->covercolor[2] = AGColor[2];
-
- check_demos(grpptr);
- /* check to see if the name has changed.
- AGName.bufpos will always be > 0 */
- if (strcmp(grpptr->nameptr->string, AGName.buf) != 0)
- {
- indexchange = TRUE;
- tmpptr = grpptr->nameptr;
- if (tmpptr != NULL)
- tmpptr->group = NULL;
- remove_keyword(tmpptr);
- grpptr->nameptr = add_keyword(AGName.buf);
- tmpptr = grpptr->nameptr;
- if (tmpptr != NULL)
- tmpptr->group = grpptr;
- }
-
- /* helpfile */
- if (AGHfile.bufpos <= 0)
- {
- if (grpptr->helpfile != NULL)
- {
- remove_file(grpptr->helpfile);
- grpptr->helpfile = NULL;
- }
- }
- else if (grpptr->helpfile != NULL && (i = strcmp(grpptr->helpfile->name, AGHfile.buf)) != 0)
- {
- {
- remove_file(grpptr->helpfile);
- grpptr->helpfile = add_file(AGHfile.buf);
- }
- }
-
- indexchange = TRUE;
- wrdptr = grpptr->keywords;
- while (wrdptr != NULL)
- {
- remove_keyword_group(wrdptr->indexptr, grpptr);
- twrd = wrdptr;
- wrdptr = wrdptr->next;
- free(twrd);
- }
- grpptr->keywords = NULL;
- charptr = HeadGrpChar;
- i = 0;
- while (charptr != NULL)
- {
- if (grpptr->keywords == NULL)
- {
- grpptr->keywords=(struct wordlist *)malloc(sizeof(struct wordlist));
- grpptr->keywords->indexptr = NULL;
- grpptr->keywords->next = NULL;
- wrdptr = grpptr->keywords;
- }
- else
- {
- wrdptr->next = (struct wordlist *)malloc(sizeof(struct wordlist));
- wrdptr = wrdptr->next;
- wrdptr->next = NULL;
- }
- i++;
- wrdptr->indexptr = add_keyword(charptr->str);
- index_add_group(wrdptr->indexptr, grpptr);
- prevcharptr = charptr->next;
- if (charptr->indexflag == 0)
- free(charptr->str);
- free(charptr);
- charptr = prevcharptr;
- }
- HeadGrpChar = NULL;
- TailGrpChar = NULL;
- grpptr->numkey = i;
- group_setup(NULL, newgroupiconlist, grpptr);
- /*
- clear_iconlist(newgroupiconlist);
- */
- newgroupiconlist = NULL;
- newgrouplasticon = NULL;
-
- if (indexchange && Indexwin >= 0)
- update_index_win();
- }
-
- /************************************************************
- *
- * Add a new group to the book.
- *
- ************************************************************/
- add_group(struct grptmpltstruct *newgrp, struct grptmpltstruct *oldgrp)
- {
- struct pagestruct *tmppg;
- struct grptmpltstruct *tmpgrp;
- int i;
- float half;
- double theta;
- long tmpwin;
- struct wordlist *wrdptr;
- struct charlist *charptr, *prevcharptr;
-
- numberofgroups++; /* this is a global variable */
- initbookpos();
- check_demos(newgrp);
- if (newgrp != NULL)
- {
- if (oldgrp == lastgroup)
- {
- lastgroup->nextgrp = newgrp;
- newgrp->prevgrp = lastgroup;
- lastgroup = newgrp;
- }
- else
- {
- oldgrp->nextgrp = newgrp;
- newgrp->prevgrp = oldgrp;
- oldgrp = newgrp;
- }
- newgrp->covercolor[0] = AGColor[0];
- newgrp->covercolor[1] = AGColor[1];
- newgrp->covercolor[2] = AGColor[2];
- if (AGName.bufpos == 0)
- if (HeadGrpChar != NULL)
- newgrp->nameptr = add_keyword(HeadGrpChar->str);
- else
- newgrp->nameptr = add_keyword("unknown");
- else
- newgrp->nameptr = add_keyword(AGName.buf);
- newgrp->nameptr->group = newgrp;
- if (AGHfile.bufpos > 0)
- newgrp->helpfile = add_file(AGHfile.buf);
- charptr = HeadGrpChar;
- i = 0;
- while (charptr != NULL)
- {
- if (newgrp->keywords == NULL)
- {
- newgrp->keywords=(struct wordlist *)malloc(sizeof(struct wordlist));
- newgrp->keywords->next = NULL;
- wrdptr = newgrp->keywords;
- }
- else
- {
- wrdptr->next = (struct wordlist *)malloc(sizeof(struct wordlist));
- wrdptr = wrdptr->next;
- wrdptr->next = NULL;
- }
- i++;
- wrdptr->indexptr = add_keyword(charptr->str);
- index_add_group(wrdptr->indexptr, newgrp);
- prevcharptr = charptr->next;
- if (charptr->indexflag == 0)
- free(charptr->str);
- free(charptr);
- charptr = prevcharptr;
- }
- HeadGrpChar = NULL;
- TailGrpChar = NULL;
- newgrp->numkey = i;
-
- group_setup(NULL, newgroupiconlist, newgrp);
- /*
- clear_iconlist(newgroupiconlist);
- */
- newgroupiconlist = NULL;
- newgrouplasticon = NULL;
- }
- if (Indexwin >= 0)
- update_index_win();
- }
-
-